import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/Index';
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'guide',
      component: ()=>import('@/views/guide')
    },
    {
      path:'/register',
      name:'register',
      component: ()=>import('@/views/register')
    },
    {
      path:'/login',
      name:'login',
      component: ()=>import('@/views/login')
    },
    //点击购买
    {
      path:'/buypro/:id',
      name:'buypro',
      component:()=>import('@/views/buypro')
    },
    //店铺
    {
      path:'/superm_shop/:id',
      name:'superm_shop',
      component:()=>import('@/views/superm_shop')
    },
    //今日特价
    {
      path:'/todayoffer/:id',
      name:'todayoffer',
      component:()=>import('@/views/todayoffer')
    },
    //到店自取
    {
       path:'/selftake/:id',
       name:'selftake',
       component:()=>import('@/views/selftake'),
    },
    //详情页
    {
      path:'/detail/:pid',
      name:'detail',
      component:()=>import('@/views/detail')
    },
    //我的收货地址
    {
      path:'/myaddress',
      name:'myaddress',
      component:()=>import('@/views/myaddress')
    },
    //主页
    {
      path:'/addAddress',
      name:'addAddress',
      component:()=>import('@/views/addAddress')
    },
    //地址编辑
    {
      path:'/editAddress/:id',
      name:'editAddress',
      component:()=>import('@/views/editAddress')
    },
    {
      path:'/index',
      redirect:'/home',
      name:'index',
      component: Index,
      //子路由  home页  超市页  购物车页面  我的页面
      children:[
        {
          path:'/home',
          name:'home',
          component: ()=>import('@/views/home')
        },
        {
          path:'/supermarket',
          name:'supermarket',
          component:()=>import('@/views/supermarket'),
         
        },
        
        
        {
          path:'/cart',
          name:'cart',
          component: ()=>import('@/views/cart')
        },
        {
          path:'/myself',
          name:'myself',
          component: ()=>import('@/views/myself')
        },
      ]
    },
    //确认订单
    {
      path:'/writeOrder/:id',
      name:'writeOrder',
      component:()=>import('@/views/WriteOrder')
    },
    //订单页
    {
      path:'/orderlist',
      name:'oderlist',
      component:()=>import('@/views/OrderList')
    },
    {
      path:'/orderdetail/:id',
      name:'orderdetail',
      component:()=>import('@/views/OrderDetail')
    },

    //分类页
    {
      path:'/category',
      redirect:'/category/prolist',
      name:'category',
      component: ()=>import('@/views/category'),
      children:[
        {
          path:'/category/prolist/:id',
          name:'prolist',
          component:()=>import('@/views/Prolist'),
          props:true,
        },
      ]
    },

  ]
})
